import random

dic = {0: '剪刀', 1: '石头', 2: '布'}

user = 50
temp = 0
try:
    while True:
        if user >= 100:
            print('用户胜利')
            break
        else:
            temp += 1
            print('第{}场'.format(temp))
            temp_pc = random.randint(0, 2)
            # print(dic[temp_pc])
            user_in = int(input("请输入[0:剪刀 1:石头 2:布]:"))
            user -= 5
            if (user_in == 0 and temp_pc == 2) or (user_in == 1 and temp_pc == 0) or (user_in == 2 and temp_pc == 1):
                user += 15
                print("你出的是%s,电脑出的是%s" % (dic[user_in], dic[temp_pc]))
                print("祝贺你，你赢了!")
                print('用户:', user)
            elif user_in == temp_pc:
                print("你出的是%s,电脑出的是%s" % (dic[user_in], dic[temp_pc]))
                print("平局")
            else:
                user -= 5
                print("你出的是%s,电脑出的是%s" % (dic[user_in], dic[temp_pc]))
                print("不好意思，你输了")
                print('用户:', user)
except KeyError:
    print('输入错误！！！')
except ValueError:
    print('输入错误！！！')
except KeyboardInterrupt:
    print("\n意外暂停")
